home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / setDrivenKeyWindow.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  22.7 KB  |  857 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|Wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. // Creation Date:  9 February 1997
  22. // Author:         jb, bb
  23. //
  24. //
  25. //  Procedure Name:
  26. //      setDrivenKeyWindow
  27. //
  28. //  Description:
  29. //              Creates a window to allow the user
  30. //              to set "driven keyframes" against
  31. //              channels - IE: one channel is used
  32. //              to drive another channel, rather than
  33. //              having time drive the value changes.
  34. //
  35. //  Input Arguments:
  36. //      None.
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41.  
  42. // globals used to so that we can key against the flexor guide
  43. // but display the guide joint rather than the guide name
  44. //
  45. global int $driversAreGuides;
  46. global string $guideDrivers[];
  47.  
  48. // Fiven a string return the name that will be used as the
  49. // item to be keyed in the setDrivenKeyframe command.
  50. //
  51. // This is needed because the $object may be a plug
  52. // on a node, a component on a shape or simply a node.
  53. //
  54. global proc string getNodeName(string $object)
  55. {
  56.     string $result;
  57.     string $buffer[3];
  58.     $numTokens = tokenize($object,".",$buffer);
  59.     if ($numTokens > 1) {
  60.         string $isAnEntity[] = `ls -type entity $buffer[0]`;
  61.         if (size($isAnEntity)) {
  62.             $result = $object;
  63.         } else {
  64.             $result = $buffer[0];
  65.         }
  66.     }
  67.     else {
  68.         $result = $object;
  69.     }
  70.     return $result;
  71. }
  72.  
  73. global proc goToDrivenKeyCallback(string $advanceFlag)
  74. //
  75. //    Description:
  76. //        If a driven attribute is selected, use it as the
  77. //        attribute to be advanced to the next/previous frame.
  78. //
  79. {
  80.     string $cmd = ("advanceToNextDrivenKey "+$advanceFlag+" ");
  81.     
  82.     // Get a driven object, and one or more selected channels
  83.     // for the driven object
  84.     //
  85.     string $driven[] = `textScrollList -q -si drivenObjects`;
  86.     string $drivenChannel[] = `textScrollList -q -si drivenChannels`;
  87.     if (1 == size($drivenChannel) && 1 == size($driven)) {
  88.         string $drivenNode = getNodeName($driven[0]);
  89.         
  90.         $cmd += ($drivenNode+"."+$drivenChannel[0]);
  91.     } else {
  92.         // The "" tells the advanceToNextDrivenKey script that
  93.         // it will operate on the selection list
  94.         //
  95.         $cmd += ("\"\"");
  96.     }
  97.  
  98.     // evaluate the advanceToNextDrivenKey command
  99.     //
  100.     eval($cmd+"\n");
  101. }
  102.  
  103. // If string $str is in list $list, returns a non-zero number
  104. // indicating the *1*-based index into the array.
  105. //
  106. global proc int isStringInList(string $str, string $list[])
  107. {
  108.     int $ii;
  109.     int $listSize = size($list);
  110.     
  111.     for ($ii = 0; $ii < $listSize; $ii++) {
  112.         if ($list[$ii] == $str) {
  113.             return ($ii+1);
  114.         }
  115.     }
  116.     return 0;
  117. }
  118.  
  119. // Special method used here to clear duplicate entries from the
  120. // list $list 
  121. //
  122. global proc removeDuplicateStringsInList(string $list[])
  123. {
  124.     int $ii, $jj;
  125.     int $listSize = size($list);
  126.  
  127.     for ($ii = 0; $ii < ($listSize-1); $ii++) {
  128.         string $checkString = $list[$ii];
  129.  
  130.         if ($checkString == "") {
  131.             continue;
  132.         }
  133.     
  134.         for ($jj = $ii+1; $jj < $listSize; $jj++) {
  135.             if ($list[$jj] == $checkString) {
  136.                 $list[$jj] = "";
  137.             }
  138.         }
  139.     }
  140. }
  141.  
  142. // given a plug name $object, strip out the $attrName
  143. //
  144. //
  145. global proc string[] sdkGetAttr(string $object)
  146. {
  147.     string $result[1];
  148.  
  149.     string $attrName = "";
  150.     string $buffer[3];
  151.     $numTokens = tokenize($object,".",$buffer);
  152.     if ($numTokens > 1) {
  153.         int $ii;
  154.         for ($ii = 1; $ii < $numTokens; $ii++) {
  155.             if ($ii != 1) {
  156.                 $attrName += ".";
  157.             }
  158.             $attrName += $buffer[$ii];
  159.         }
  160.     }
  161.     $result[0] = $attrName;
  162.     return $result;
  163. }
  164.  
  165. // Return a mel command appropriate for the given object.
  166. // If $driver is true, consider nonkeyable attributes in addition
  167. // to keyable.
  168. //
  169. global proc string genListAttrString(int $driver,string $object) {
  170.  
  171.     string $cmd;
  172.  
  173.     string $buffer[3];
  174.     $numTokens = tokenize($object,".",$buffer);
  175.     string $isAnEntity[] = `ls -type entity $buffer[0]`;
  176.     if ($numTokens > 1 && (0 == size($isAnEntity))) {
  177.         // If the object name has embedded .'s and the $object type
  178.         // is not an entity, the assumption here is that the $object
  179.         // is a plug rather than a component on a shape.
  180.         //
  181.         // In this case we take the attribute name directly from the plug
  182.         // since a listAttr command would list all the attributes instead of
  183.         // only the selected attribute
  184.         //        
  185.         $cmd = "sdkGetAttr ";
  186.     }
  187.     else {
  188.         $cmd = "listAttr -sa -v -c -u -m -lf ";
  189.  
  190.         // only show the keyable attributes unless the showNonKeyable
  191.         // option is true
  192.         //
  193.         int $showNonKeyable = `optionVar -query SDKshowNonKeyable`;
  194.  
  195.         if ($driver == 0 && ! $showNonKeyable) {
  196.             $cmd += "-k ";
  197.         }
  198.  
  199.         // because there are so many attributes on transforms, we only
  200.         // list the keyable attributes for them when listing the driver
  201.         //
  202.         string $xforms[] = `ls -type transform $object`;
  203.         if ($driver && size($xforms)) {
  204.             $cmd += "-k ";
  205.         }
  206.     }
  207.  
  208.     $cmd += $object;
  209.     return $cmd;
  210. }
  211.  
  212. global proc generateSetDrivenCommand( )
  213. //
  214. //      Generate a setDrivenKeyframe command for
  215. //      each of the selected channels in the driven channel
  216. //      text scroll list.
  217. {
  218.     global int $driversAreGuides;
  219.     global string $guideDrivers[];
  220.     
  221.     // Get a driver, and the selected channel for the driver
  222.     //
  223.     string $driver[] = `textScrollList -q -si driverObjects`;
  224.     string $driverChannel[] = `textScrollList -q -si driverChannels`;
  225.     // Get a driven object, and one or more selected channels
  226.     // for the driven object
  227.     //
  228.     string $driven[] = `textScrollList -q -si drivenObjects`;
  229.     string $drivenChannel[] = `textScrollList -q -si drivenChannels`;
  230.     string $cmd;
  231.  
  232.     if (0 == size($driver)
  233.     ||  0 == size($driverChannel)) {
  234.         error("Must select node and attribute to be the driver.");
  235.         return;
  236.     }
  237.  
  238.     if (0 == size($driven)
  239.     ||  0 == size($drivenChannel)) {
  240.         error("Must select node and attribute to be driven.");
  241.     }    
  242.  
  243.     int $i, $j, $which;
  244.     for ( $i=0; $i < size( $driven ); $i++ ) {
  245.  
  246.         string $drivenNode = getNodeName($driven[$i]);
  247.         
  248.         for( $j=0; $j < size( $drivenChannel ); $j++ )
  249.         {
  250.             $cmd = "setDrivenKeyframe -cd ";
  251.  
  252.             if ($driversAreGuides) {
  253.                 // if a guide node is in the driver list, key against the
  254.                 // driver node rather than the joint 
  255.                 //
  256.                 string $guides[] = `textScrollList -q -ai driverObjects`;
  257.                 $which = isStringInList($driver[0],$guides) - 1;
  258.                 $cmd = ( $cmd +
  259.                          $guideDrivers[$which] + "." +
  260.                          $driverChannel[0] + " " );
  261.             } else {
  262.                 $cmd = ( $cmd + $driver[0] + "." + $driverChannel[0] + " " );
  263.             }
  264.             
  265.             $cmd = ( $cmd + $drivenNode + "." + $drivenChannel[$j] );
  266.  
  267.             // 
  268.             // Evaluate and echo the command for the users benefit
  269.             //
  270.             evalEcho( $cmd );
  271.         }
  272.     }
  273. }
  274.  
  275. global proc selectDriven( )
  276. //
  277. //      callback used to select all driven objects
  278. //
  279. {
  280.     string $driven[] = `textScrollList -q -si drivenObjects`;
  281.     if (size($driven) && $driven[0] != "< Nothing Selected >") {
  282.         select -r $driven;
  283.     }
  284. }
  285.  
  286. global proc updateKeyButton( )
  287. //
  288. //      Called any time that selection are made in the
  289. //      driver and driven channels textScrollLists, in order
  290. //      to update the state of the "Key" button.  The user
  291. //      must select: a driver object, a driven object, and
  292. //      channels for both driver and driven before the "Key"
  293. //      button is enabled.
  294. {
  295.     if( `textScrollList -q -nsi driverChannels` != 0 &&
  296.     `textScrollList -q -nsi drivenChannels` != 0 ) 
  297.     {
  298.         button -e -enable true keyButton;
  299.     } else {
  300.         button -e -enable false keyButton;
  301.     }
  302. }
  303.  
  304. global proc updateChannels( string $list, string $channelList )
  305. //
  306. //      Called whenever a new object is selected in
  307. //      either the driver or driven object textScrollList's,
  308. //      in order to fill the corresponding channel list
  309. //      with a list of keyable channels for the driver or
  310. //      driven objects.
  311. {
  312.     global int $driversAreGuides;
  313.     global string $guideDrivers[];
  314.     
  315.     int $driver = ($list == "driverObjects");
  316.  
  317.     string $currChannels[] = `textScrollList -q -si $channelList`;
  318.     string $object[] = `textScrollList -q -si $list`;
  319.  
  320.     if ($list == "driverObjects" && $driversAreGuides) {
  321.         int $which;
  322.         string $allObjects[] = `textScrollList -q -ai $list`;
  323.         $which = isStringInList($object[0],$allObjects) - 1;
  324.  
  325.         if ($which > -1)
  326.             $object[0] = $guideDrivers[$which];
  327.     }
  328.     
  329.     string $listAttrCmd = genListAttrString($driver,
  330.                                             $object[0]);
  331.     
  332.     string $attrs[] = eval( $listAttrCmd );
  333.     removeDuplicateStringsInList($attrs);
  334.     textScrollList -e -ra $channelList;
  335.  
  336.     int $ii, $jj;
  337.     int $attrCount = size($attrs);
  338.     for ($ii = 1; $ii < size($object); $ii++) {
  339.         $listAttrCmd = genListAttrString($driver,
  340.                                          $object[$ii]);
  341.  
  342.         string $attrs2[] = eval( $listAttrCmd );
  343.         for ($jj = 0; $jj < $attrCount; $jj++) {
  344.             if ($attrs[$jj] == "") { continue; }
  345.             if (! isStringInList($attrs[$jj],$attrs2)) {
  346.                 $attrs[$jj] = "";
  347.             }
  348.         }
  349.     }
  350.  
  351.     int $selectChannels = 0;
  352.     string $selChannels = "textScrollList -e ";
  353.     for( $item in $attrs )
  354.     {
  355.         if ($item != "") {
  356.             if (isStringInList($item,$currChannels)) {
  357.                 $selectChannels = 1;
  358.                 $selChannels += "-si "+$item+" ";
  359.             }
  360.             textScrollList -e -a $item $channelList;
  361.         }
  362.     }
  363.  
  364.     if ($selectChannels) {
  365.         $selChannels += $channelList;
  366.         eval($selChannels);
  367.     }
  368. }
  369.  
  370.  
  371. global proc loadCurrentDriver()
  372. //
  373. // Query the currently selected driven object and if it has
  374. // any drivers, load them in the driver lists.
  375. //
  376. {
  377.     global int $driversAreGuides = 0;
  378.     global string $guideDrivers[];
  379.     
  380.     string $driverNodes[];
  381.     string $currentNode;
  382.     string $currentAttr;
  383.     string $objects[] = `textScrollList -q -si drivenObjects`;
  384.     string $attrs[] = `textScrollList -q -si drivenChannels`;
  385.  
  386.     textScrollList -e -ra driverObjects;
  387.     textScrollList -e -ra driverChannels;
  388.     if (size($objects)
  389.         && ($objects[0] != "< Nothing Selected >") ) {
  390.         string $queryString = "setDrivenKeyframe -q -dr "+$objects[0];
  391.         string $currentString = "setDrivenKeyframe -q -cd "+$objects[0];
  392.         if (size($attrs)) {
  393.             $queryString += "."+$attrs[0];
  394.             $currentString += "."+$attrs[0];
  395.         }
  396.  
  397.         string $current[] = eval($currentString);
  398.         string $drivers[] = eval($queryString);
  399.         if ( size($drivers) &&
  400.              ($drivers[0] == "No drivers." ||
  401.               $drivers[0] == "") )
  402.         {
  403.             $drivers = `setDrivenKeyframe -q -dr ($objects[0])`;
  404.             $current = `setDrivenKeyframe -q -cd ($objects[0])`;
  405.         }
  406.  
  407.         string $buffer[];
  408.         // tokenize the result into nodes and attrs
  409.         //
  410.         if ($current[0] != "No drivers.") {
  411.             if (2 == tokenize($current[0], ".", $buffer))
  412.             {
  413.                 $currentNode = $buffer[0];
  414.                 $currentAttr = $buffer[1];
  415.             }
  416.         }
  417.         
  418.         int $ii;
  419.         int $counter = 0;
  420.         clear $guideDrivers;
  421.         for ($ii = 0; $ii < size($drivers); $ii++)
  422.         {
  423.             if ($drivers[$ii] != "No drivers." && $drivers[$ii] != "")
  424.             {
  425.                 if (2 == tokenize($drivers[$ii], ".", $buffer))
  426.                 {
  427.                     string $cds[] = `textScrollList -q -ai driverObjects`;
  428.  
  429.                     string $nameToUse;
  430.                     if (nodeType($buffer[0]) == "guide") {
  431.                         string $sArr[];
  432.                         $sArr = `listConnections -d false ($buffer[0]+".jointXformMatrix")`;
  433.  
  434.                         if (0 != size($sArr)) {
  435.                             $driversAreGuides = 1;
  436.                             $nameToUse = $sArr[0];
  437.  
  438.                             if ($buffer[0] == $currentNode) {
  439.                                 $currentNode = $nameToUse;
  440.                                     
  441.                             }
  442.                         } else {
  443.                             $nameToUse = $buffer[0];
  444.                         }
  445.                     } else {
  446.                         $nameToUse = $buffer[0];
  447.                     }
  448.                     
  449.                     if (! isStringInList($nameToUse,$cds) ) {
  450.  
  451.                         textScrollList -e -a $nameToUse driverObjects;
  452.                         $guideDrivers[$counter] = $buffer[0];
  453.                         $counter++;
  454.                         
  455.                     }
  456.                 }
  457.             }
  458.         }
  459.  
  460.         if ($currentNode != "") {
  461.             textScrollList -e -si $currentNode driverObjects;
  462.             updateChannels driverObjects driverChannels;
  463.             textScrollList -e -si $currentAttr driverChannels;
  464.             textScrollList -e -enable true driverObjects;
  465.         }
  466.     }
  467. }
  468.  
  469. global proc selectListItems(string $list)
  470. //
  471. //      Called whenever a new object is selected in
  472. //      the driven object textScrollList.
  473. //      If the select driven checkbox is selected, selects
  474. //      the current driven item.
  475. //
  476. {
  477.     if (`optionVar -q SDKselectListItems`) {
  478.         string $objects[] = `textScrollList -q -si $list`;
  479.         if (size($objects)
  480.         && ($objects[0] != "< Nothing Selected >") ) {
  481.             select -replace $objects;
  482.         }
  483.     }
  484. }
  485.  
  486. proc fillObjectList( string $list, string $node, string $attr)
  487. //
  488. //      Called by the updateSetDrivenWnd proc, in
  489. //      order to fill the textScrollLists with a list
  490. //      of available objects for each.
  491. //
  492. //      If $node and $attr are not "", these items are used as the
  493. //      driven items. Else if they are "", the selection list is used
  494. //      to fill the specified text scroll list.
  495. //
  496. //      If nothing is selected when the user performs this operation,
  497. //      the textScrollList is disabled, and the string
  498. //      < Nothing Selected > is put into the list.
  499. //    
  500. {
  501.     global int $driversAreGuides;
  502.     global string $guideDrivers[];
  503.  
  504.     // find current selection list
  505.     //
  506.     string $objects[20];
  507.     if (! (`optionVar -query SDKshowShapes`)) {
  508.         $objects = `ls -sl`;
  509.     } else {
  510.         $objects = `listRelatives -shapes`;
  511.     }
  512.     
  513.     // determine whether current list should be cleared
  514.     //
  515.     int $selectedSomething = 0;
  516.     string $currObjects[] = `textScrollList -q -ai $list`;
  517.     if (`optionVar -query SDKclearOnLoad`) {
  518.         textScrollList -e -ra $list;
  519.         if ($list == "driverObjects")
  520.             $driversAreGuides = 0;
  521.     } else if (1 == `textScrollList -q -ni $list`
  522.            &&  "< Nothing Selected >" == $currObjects[0]) {
  523.         textScrollList -e -ra $list;
  524.         if ($list == "driverObjects")
  525.             $driversAreGuides = 0;
  526.     } else {
  527.         textScrollList -e -da $list;
  528.     }
  529.  
  530.     // find current contents of textScrollList
  531.     //
  532.     $currObjects = `textScrollList -q -ai $list`;
  533.  
  534.     int $counter = size($guideDrivers);
  535.     
  536.     // fill list
  537.     //
  538.     if ( $node == "" ) {
  539.         if( `size( $objects )` == 0 )
  540.             //      Nothing selected - disable the control,
  541.             //      and put in a string that informs the user
  542.             //      that they have nothing selected to load
  543.             //      into the textScrollList
  544.         {
  545.             textScrollList -e -ra $list;            
  546.             textScrollList -e -a "< Nothing Selected >" $list;
  547.             textScrollList -e -enable false $list;
  548.             button -e -enable false keyButton;
  549.             return;
  550.         }
  551.         
  552.         for( $item in $objects )
  553.         {
  554.             textScrollList -e -enable true $list;
  555.             if (! isStringInList($item,$currObjects)) {
  556.                 textScrollList -e -a $item $list;
  557.                 $guideDrivers[$counter] = $item;
  558.                 $counter++;
  559.             }
  560.         }
  561.         if (1 == `textScrollList -q -ni $list`) {
  562.             textScrollList -e -sii 1 $list;
  563.             $selectedSomething = 1;
  564.         }
  565.     } else {
  566.         textScrollList -e -a $node $list;
  567.         int $listSize = `textScrollList -q -ni $list`;
  568.         textScrollList -e -sii $listSize $list;
  569.         $selectedSomething = 1;
  570.     }
  571.  
  572.     if ($selectedSomething == 1) {
  573.         if ($list == "drivenObjects") {
  574.             updateChannels drivenObjects drivenChannels;
  575.  
  576.             if ($attr != "") {
  577.                 // $attr might be the name of a compound.  If so, get something
  578.                 // we're actually listing in the 
  579.                 string $listAttrCmd = 
  580.                     genListAttrString( 0, "" ) + ($node+"."+$attr);
  581.                 
  582.                 string $resultAttrs[] = eval( $listAttrCmd );
  583.                 if( size( $resultAttrs ) > 0 ) {
  584.                     textScrollList -e -si $resultAttrs[0] drivenChannels;
  585.                 }
  586.             }
  587.         } else {
  588.             updateChannels driverObjects driverChannels;
  589.         }
  590.     }
  591. }
  592.  
  593.  
  594.  
  595.  
  596. global proc updateSetDrivenWnd( string $which, string $node, string $attr )
  597. //
  598. //  Called whenever the user clicks on either the
  599. //  "Load Driver" or "Load Driven" buttons.  This
  600. //  proc will fill the driver and driven object
  601. //  lists.
  602. {
  603.     switch( $which ) {
  604.         case "driver":
  605.             textScrollList -e -ra driverChannels;
  606.             fillObjectList("driverObjects","","");
  607.             button -e -enable false keyButton;
  608.             break;
  609.         case "driven":
  610.             textScrollList -e -ra drivenChannels;
  611.             fillObjectList("drivenObjects",$node,$attr);
  612.             button -e -enable false keyButton;
  613.             break;
  614.     }
  615. }
  616.  
  617. global proc buildSetDrivenKeyContextHelpItems(string $nameRoot, string $menuParent)
  618. {
  619.     menuItem -label "Help on Set Driven Key..."
  620.         -enableCommandRepeat false
  621.         -command "showHelp SetDrivenKey";
  622. }
  623.  
  624. proc createSetDrivenWnd()
  625. //
  626. //      Creates the setDriveKeyframe window, with
  627. //      four textScrollLists, one for each of the driver
  628. //      and driven objects, and their channels.
  629. //
  630. //      Also creates a "Key" button to key the currently
  631. //      selected items, "Load Driver" and "Load Driven"
  632. //      buttons to load the selected objects into the
  633. //      driver and driven lists, and a "Close" button,
  634. //      to allow the user to close the window without
  635. //      having to double click on the close box.
  636. //
  637. //      If the window already exists, then the proc
  638. //      simply shows the window, effectively popping it
  639. //      to the top, if it's under other windows.
  640. {
  641.     window -t "Set Driven Key"
  642.         -retain
  643.         -iconName "Set Driven" -mb true
  644.         -s true -wh 390 530 setDrivenWnd;
  645.     
  646.     menu -l "Load" -to true;
  647.     menuItem -l "Selected as Driver"
  648.         -c "updateSetDrivenWnd(\"driver\",\"\",\"\")";
  649.     menuItem -l "Selected as Driven"
  650.         -c "updateSetDrivenWnd(\"driven\",\"\",\"\")";
  651.     menuItem -l "Current Driver"
  652.         -c "loadCurrentDriver";
  653.     setParent -m ..;
  654.  
  655.     optionVar -iv SDKclearOnLoad 1;
  656.     optionVar -iv SDKshowShapes 0;
  657.     optionVar -iv SDKselectListItems 1;
  658.     optionVar -iv SDKshowNonKeyable 0;
  659.     
  660.      menu -l "Options" -to true;
  661.      menuItem -l "Clear on Load" -cb 1
  662.          -c ("optionVar -iv SDKclearOnLoad #1;");
  663.      menuItem -l "Load shapes" -cb 0
  664.          -c ("optionVar -iv SDKshowShapes #1;");
  665.      menuItem -l "AutoSelect" -cb 1
  666.          -c ("optionVar -iv SDKselectListItems #1;");
  667.      menuItem -l "List Keyable Driven Attributes" -cb 1
  668.          -c ("optionVar -iv SDKshowNonKeyable (!(#1)); updateChannels drivenObjects drivenChannels");
  669.      setParent -m ..;
  670.  
  671.     // Mimic the Set Driven Key portion of the Key menu in AniKeyframeMenu.mel
  672.     //
  673.     menu -l "Key" -to true;
  674.         
  675.     menuItem -label "Set" -command "generateSetDrivenCommand"
  676.         setDrivenKeyItem;
  677.     menuItem -divider true;
  678.  
  679.     menuItem -label "Go to Previous"
  680.         -command "goToDrivenKeyCallback -previous"
  681.         previousDrivenKeyItem;
  682.  
  683.     menuItem -label "Go to Next"
  684.         -command "goToDrivenKeyCallback -next"
  685.         nextDrivenKeyItem;        
  686.     setParent -menu ..;
  687.     
  688.      menu -l "Select" -to true;
  689.      menuItem -l "Driven Items" -c "selectDriven";
  690.      setParent -m ..;                    
  691.  
  692.     //    Adds support for the Context Sensitive Help Menu.
  693.     //
  694.     addContextHelpProc "setDrivenWnd" "buildSetDrivenKeyContextHelpItems";
  695.  
  696.     doHelpMenu "setDrivenWnd" "setDrivenWnd";
  697.  
  698.     setParent -m ..;
  699.  
  700.     formLayout setDrivenForm;
  701.     formLayout objectsForm;
  702.     frameLayout -l "Driver" 
  703.         -bv true -bs "etchedIn" -la "center"
  704.         -cl false -cll false 
  705.         -mh 10 -mw 10
  706.         driverLayout;
  707.     
  708.     formLayout driverForm;
  709.     textScrollList 
  710.         -ams false 
  711.         -sc "updateChannels driverObjects driverChannels;  selectListItems driverObjects;"
  712.         driverObjects;
  713.     textScrollList 
  714.         -ams false 
  715.         -sc "updateKeyButton"
  716.         driverChannels;
  717.     setParent ..;
  718.     
  719.     formLayout -e
  720.         -af driverObjects top 0
  721.         -af driverObjects left 0
  722.         -ap driverObjects right 0 50
  723.         -af driverObjects bottom 0
  724.         
  725.         -af driverChannels top 0
  726.         -ac driverChannels left 0 driverObjects
  727.         -af driverChannels right 0
  728.         -af driverChannels bottom 0
  729.         driverForm;
  730.     
  731.     setParent ..;
  732.     
  733.     frameLayout -l "Driven" 
  734.         -bv true -bs "etchedIn" -la "center"
  735.         -cl false -cll false 
  736.         -mh 10 -mw 10
  737.         drivenLayout;
  738.     
  739.     formLayout driverForm;
  740.     textScrollList 
  741.         -ams true
  742.         -sc "updateChannels drivenObjects drivenChannels; selectListItems drivenObjects;"
  743.         drivenObjects;
  744.     textScrollList 
  745.         -sc "updateKeyButton"
  746.         -ams true 
  747.         drivenChannels;
  748.     setParent ..;
  749.     
  750.     formLayout -e
  751.         -af drivenObjects top 0
  752.         -af drivenObjects left 0
  753.         -ap drivenObjects right 0 50
  754.         -af drivenObjects bottom 0
  755.         
  756.         -af drivenChannels top 0
  757.         -ac drivenChannels left 0 drivenObjects
  758.         -af drivenChannels right 0
  759.         -af drivenChannels bottom 0
  760.         driverForm;
  761.     
  762.     setParent ..;
  763.     setParent ..;
  764.     
  765.     formLayout -e
  766.         -af driverLayout top 2
  767.         -af driverLayout left 2
  768.         -af driverLayout right 2
  769.         -ap driverLayout bottom 2 50
  770.         
  771.         -ac drivenLayout top 2 driverLayout
  772.         -af drivenLayout left 2
  773.         -af drivenLayout right 2
  774.         -af drivenLayout bottom 2
  775.         objectsForm;
  776.     
  777.     formLayout buttonForm;
  778.     button -l "Key" 
  779.         -enable false
  780.         -annotation "Set key for current relationship of driver attribute to driven attribute"
  781.         -c "generateSetDrivenCommand" keyButton;
  782.     button -l "Load Driver"
  783.         -annotation "Load selected as driver"
  784.         -c "updateSetDrivenWnd(\"driver\",\"\",\"\")" updateDriver;        
  785.     button -l "Load Driven"
  786.         -annotation "Load selected as driven"
  787.         -c "updateSetDrivenWnd(\"driven\",\"\",\"\")" updateDriven;        
  788.     button -l "Close"
  789.         -c "window -e -vis 0 setDrivenWnd"
  790.         closeButton;
  791.     setParent ..;
  792.     
  793.     formLayout -e
  794.         -af keyButton left 2
  795.         -af keyButton top 5
  796.         -af keyButton bottom 5
  797.         -ac keyButton right 2 updateDriver
  798.         
  799.         -ap updateDriver left 5 25
  800.         -af updateDriver top 5
  801.         -af updateDriver bottom 5
  802.         -ap updateDriver right 1 50
  803.  
  804.         -ap updateDriven left 1 50
  805.         -af updateDriven top 5
  806.         -af updateDriven bottom 5
  807.         -ap updateDriven right 5 75
  808.  
  809.         -af closeButton top 5
  810.         -ac closeButton left 2 updateDriven
  811.         -af closeButton right 2
  812.         -af closeButton bottom 5
  813.         buttonForm;
  814.  
  815.     setParent ..;
  816.  
  817.     formLayout -e
  818.         -af buttonForm bottom 5
  819.         -af buttonForm left 5
  820.         -af buttonForm right 5
  821.  
  822.         -af objectsForm top 5
  823.         -af objectsForm left 5
  824.         -af objectsForm right 5
  825.         -ac objectsForm bottom 5 buttonForm
  826.  
  827.         setDrivenForm;
  828. }
  829.  
  830. global proc clearSDKwindow() {
  831.     if( `window -exists setDrivenWnd` ) {
  832.         updateSetDrivenWnd("driven","","");
  833.         updateSetDrivenWnd("driver","","");        
  834.     }    
  835. }
  836.  
  837. global proc setDrivenKeyWindow(string $node, string $attr)
  838. {
  839.     $driversAreGuides = 0;
  840.     
  841.     if( `window -exists setDrivenWnd` ) {
  842.         showWindow setDrivenWnd;
  843.     } else {
  844.         // create the window
  845.         //
  846.         createSetDrivenWnd();
  847.  
  848.         scriptJob -protected
  849.             -parent "setDrivenWnd"
  850.             -conditionTrue deleteAllCondition clearSDKwindow;
  851.     }
  852.     
  853.     updateSetDrivenWnd("driven",$node,$attr);
  854.     loadCurrentDriver;
  855.     showWindow setDrivenWnd;
  856. }
  857.